namespace Guia.Locator
{
    using System.Reflection;
    using Elements;

    /// <summary>
    /// This class is used to get the SearchCondition for a particular UIElement-Type
    /// </summary>
    public static class ControlTypeDirectory
    {
        /// <summary>
        /// Returns the SearchCondition for a given UiElement type
        /// </summary>
        /// <typeparam name="T">Type of the UiElement</typeparam>
        /// <returns>SeachCondition for the given UiElement</returns>
        public static SearchCondition GetConditionForType<T>() where T : UiElement
        {
            PropertyInfo fieldInfo = typeof(T).GetProperty("ControlTypeCondition");
            SearchCondition controlTypeCondition = (SearchCondition) fieldInfo.GetValue(null, null);
            return controlTypeCondition;
        }
    }
}